#include <iostream>
using namespace std;

int main() {
    int m,n;
    cin >> m >> n;
    int a[m][n], b[m][n];
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> b[i][j];
        }
    }

    double total;
    double same;
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            total++;
            if (a[i][j] == b[i][j])
            {
                same++;
            }
        }
    }
    printf("%.2f", same * 100 / total);
    
    return 0;
}